<?php

namespace App\Models;

use Mockery\Exception;

class Announcement extends Base
{
    // 数据表主键
    public $timestamps = false;
    protected $table = 'announcements';
    protected $dates = ['created_at', 'updated_at'];

    public function one_user()
    {
        return $this->hasOne(AdminEstate::class, "id", "author");
    }

    /**
     * Notes: 添加
     * User: HK
     * Date: 2021/2/3
     * Time: 14:36
     * email: 1919194843@qq.com
     */
    public function create($data)
    {
        $data['create_time'] = time();
        return self::addInfo($data);
    }

    /**
     * Notes: 删除
     * User: HK
     * Date: 2021/2/3
     * Time: 14:59
     * email: 1919194843@qq.com
     * @param $ids
     * @return bool
     */
    public function deletes($ids)
    {
        $ids = explode(',', $ids);
        try {
            foreach ($ids as $key => $val) {
                self::delByWhere(['id' => $val]);
            }
            return true;
        } catch (Exception $exception) {
            return false;
        }
    }
}
